<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>完善需求</title>


    <!-- Expand styles -->
    <link href="../css/app/app.css" rel="stylesheet">
    <link href="../css/app/default.css" rel="stylesheet">
    <link href="../css/mui/mui.css" rel="stylesheet">
    <link href="../css/mui/mui.picker.min.css" rel="stylesheet" />

</head>

<body>


    <!-- header -->
    <div class="margin-b-60">
        <div class="list-group patient-list1 margin-b-i10">
            <div class="list-cell text-cell list-cell1" onclick="selectTrainType()">
                <div class="web-box1 list-left">培训类型</div>
                <div class="web-box2 nk-s text-right list-right">
                    <div class="display-flex align-items-center justify-content-center">
                        <input type="text" placeholder="请选择" id="tranType" disabled>
                        <input type="hidden" id="tranTypeCode">
                        <img class="sele-icon" src="../img/next.png" />
                    </div>
                </div>
            </div>
            <div class="list-cell text-cell list-cell1" onclick="selectStartTime()">
                <div class="web-box1 list-left">培训开始时间</div>
                <div class="web-box2 nk-s text-right list-right">
                    <div class="display-flex align-items-center justify-content-center">
                        <input type="text" placeholder="请选择" id="tranBeginTime" disabled>
                        <img class="sele-icon" src="../img/next.png" />
                    </div>
                </div>
            </div>
            <div class="list-cell text-cell list-cell1" onclick="selectEndTime()">
                <div class="web-box1 list-left">培训结束时间</div>
                <div class="web-box2 nk-s text-right list-right">
                    <div class="display-flex align-items-center justify-content-center">
                        <input type="text" placeholder="请选择" id="tranEndTime" disabled>
                        <img class="sele-icon" src="../img/next.png" />
                    </div>
                </div>
            </div>
            <div class="list-cell text-cell list-cell1" onclick="selectQuoteEndTime()">
                <div class="web-box1 list-left">报价截止时间</div>
                <div class="web-box2 nk-s text-right list-right">
                    <div class="display-flex align-items-center justify-content-center">
                        <input type="text" placeholder="请选择" id="quoteDeadline" disabled>
                        <img class="sele-icon" src="../img/next.png" />
                    </div>
                </div>
            </div>
           
        </div>
        <div class="list-group patient-list1 margin-b-i10">
            <!-- <div class="price-diff"> -->
            <div class="list-cell text-cell">
                <div class="web-box1 list-left">费用预算</div>
                <div class="web-box2 nk-s text-right list-right display-flex">
                    <input type="tel" placeholder="请输入金额" onkeyup="priceCheck(this)" maxlength="10" id="budget">
                    <span class="padding-l-5 font-15 black">元</span>
                </div>
            </div>
            <div class="list-cell text-cell list-cell1">
                <div class="web-box1 list-left">培训主办方</div>
                <div class="web-box2 nk-s text-right list-right"><input type="text" placeholder="请输入培训主办方" id="tranSponsors">
                </div>
            </div>
            <div class="list-cell text-cell list-cell1">
                <div class="web-box1 list-left">培训联系人</div>
                <div class="web-box2 nk-s text-right list-right"><input type="text" placeholder="请输入培训联系人" id="tranConnectPersion">
                </div>
            </div>
            <div class="list-cell text-cell list-cell1" onclick="showAddress()">
                <div class="web-box1 list-left">培训地点</div>
                <div class="web-box2 nk-s text-right list-right">
                    <div class="display-flex align-items-center justify-content-center">
                        <input type="text" placeholder="请选择" id="address" autocomplete="off" disabled>
                        <img class="sele-icon" src="../img/next.png" />
                    </div>
                </div>
            </div>
            <div class="list-cell text-cell list-cell1">
                <div class="web-box1 list-left">详细地址</div>
                <div class="web-box2 nk-s text-right list-right"><input type="text" placeholder="请输入详细地址" id="tranAddress">
                </div>
            </div>

        </div>
        <div class="widget-default widget-body margin-b-10">

            <div class="web-box1 list-left font-16 black">培训要求</div>
            <div class="list-right">
                <textarea class="no-margin info-textarea" type="text" placeholder="简单介绍一下你的培训要求吧！" id="details"></textarea>
            </div>

        </div>
    </div>
    <div class="save-btn hobby-footer1">
        <button type="button" class="mui-btn mui-btn-primary mui-btn-block bc-head" onclick="save()">发布</button>
    </div>

    <script src="../js/dsbridge.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/mui/mui.js"></script>
    <script src="../js/mui/mui.picker.min.js"></script>
    <script src="../js/layer.js"></script>
    <script src="../js/city.data-3.js"></script>
    <script src="../js/app/app-base.js"></script>
    <script src="../js/app/app-url.js"></script>
    <script src="../js/app/app-ajax.js"></script>
    <script>
        //省code
        var provinceCode = "";
        //市code
        var cityCode = "";
        //区code
        var countyCode = "";
        //培训类型选择
        var trainTypePicker = new mui.PopPicker();
        //时间选择
        var dtpicker = new mui.DtPicker({
            type: "datetime"
        })
        //地址选择
        var pickerAddress = new mui.PopPicker({
            layer: 3
        });
        $(document).ready(function(){
            pickerAddress.setData(cityData3);
            //获取培训类型
            getTrainType();
        })

        //获取培训类型
        function getTrainType(){
            var data = {
                pCode:'TRAN_TYPE'
            }
            getServerData(url_businessdatamng_queryList, data);
        }

        //选择培训类型
        function selectTrainType(){
            trainTypePicker.show(function (item) {
                $("#tranType").val(item[0].text);
                $("#tranTypeCode").val(item[0].value);
            });
        }

        //选择培训开始时间
        function selectStartTime(){
            dtpicker.show(function (e) {
                $("#tranBeginTime").val(e.text);
            })
        }

        //选择培训结束时间
        function selectEndTime(){
            dtpicker.show(function (e) {
                $("#tranEndTime").val(e.text);
            })
        }

        //选择报价截止时间
        function selectQuoteEndTime(){
            dtpicker.show(function (e) {
                $("#quoteDeadline").val(e.text);
            })
        }

        //选择地址
        function showAddress() {
            pickerAddress.show(function (item) {
                provinceCode = emptyShow(item[0].value);
                cityCode = emptyShow(item[1].value);
                countyCode = emptyShow(item[2].value);
                var address = item[0].text + emptyShow(item[1].text) + emptyShow(item[2].text);
                $("#address").val(address);
            });
        }

        //保存
        function save(){
            var publishDemandObj = strToJson(localStorage.getItem("publishDemandObj"));
            var tranTypeCode = $("#tranTypeCode").val();
            var tranBeginTime = $("#tranBeginTime").val();
            var tranEndTime = $("#tranEndTime").val();
            var quoteDeadline = $("#quoteDeadline").val();
            var budget = $("#budget").val();
            var tranSponsors = $("#tranSponsors").val();
            var tranConnectPersion = $("#tranConnectPersion").val();
            var tranAddress = $("#tranAddress").val();
            var details = $("#details").val();
            if(isEmpty(tranTypeCode)){
                showToast("请选择培训类型");
                return;
            }
            if(isEmpty(tranBeginTime)){
                showToast("请选择培训开始时间");
                return;
            }
            if(isEmpty(tranEndTime)){
                showToast("请选择培训结束时间");
                return;
            }
            if(isEmpty(quoteDeadline)){
                showToast("请选择报价截止时间");
                return;
            }
            if(isEmpty(budget)){
                showToast("请输入费用预算");
                return;
            }
            if(isEmpty(tranSponsors)){
                showToast("请输入培训主办方");
                return;
            }
            if(isEmpty(tranConnectPersion)){
                showToast("请输入培训联系人");
                return;
            }
            if(isEmpty(provinceCode)){
                showToast("请选择培训地点");
                return;
            }
            if(isEmpty(tranAddress)){
                showToast("请输入详细地址");
                return;
            }
            var data = {
                userAccId:getUserId(),
                title:publishDemandObj.title,
                tranPeopleNum:publishDemandObj.tranPeopleNum,
                connectPhone:publishDemandObj.connectPhone,
                tranTypeCode:tranTypeCode,
                tranBeginTime:tranBeginTime,
                tranEndTime:tranEndTime,
                quoteDeadline:quoteDeadline,
                budget:budget,
                tranSponsors:tranSponsors,
                tranConnectPersion:tranConnectPersion,
                provinceCode:provinceCode,
                cityCode:cityCode,
                countyCode:countyCode,
                tranAddress:tranAddress,
                details:details
            }
            getServerData(url_trandemandmgr_save, data);
        }

        function getServerDataSuccess(url, data) {
            switch (url) {
                case url_businessdatamng_queryList:
                    //培训类型
                    data = data.data;
                    var trainTypePickerArray = new Array();
                    if(data != null && data.length > 0){
                        $.each(data,function(index,item){
                            var obj = {
                                value: item.code,
                                text: item.name
                            }
                            trainTypePickerArray.push(obj);
                        })
                    }
                    trainTypePicker.setData(trainTypePickerArray);
                    break;
                case url_trandemandmgr_save:
                    //保存
                    //信息框
                    layer.open({
                        content: "发布成功",
                        btn: '确定',
                        shadeClose:false,
                        yes: function (index) {
                            layer.close(index);
                            dsBridge.call("saveClose","");
                        }
                    });
                    break;
                case url_trandemandmgr_queryList:
                    
                    break;
            }
        }

        

    </script>

</body>

</html>